//package transport.handler;
//
//import hdfs.TransPort;
//import io.netty.buffer.ByteBuf;
//import io.netty.buffer.Unpooled;
//import io.netty.channel.*;
//import io.netty.util.CharsetUtil;
//import io.netty.util.ReferenceCountUtil;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import transport.ChannelUtils;
//
//import java.io.*;
//import java.nio.charset.StandardCharsets;
//
//public final class EndHandler extends WriteHandler {
//    private static final Logger LOG = LoggerFactory.getLogger(EndHandler.class);
//
//    public EndHandler(String storagePath, EventLoopGroup aGroup,EventLoopGroup wGroup) throws FileNotFoundException {
//        super(storagePath,aGroup,wGroup);
//    }
//
//    @Override
//    public void channelRead(ChannelHandlerContext ctx, Object msg) throws IOException {
//
//        TransPort.WritePacketRequest req = (TransPort.WritePacketRequest) msg;
//        LOG.debug("{} 获取到Packet{}",ctx.channel().localAddress(),req.getSize());
//        writer.write(req.getData().toByteArray(),0,req.getSize());
//        writer.flush();
//
////        TransPort.WritePacketResponse.Builder rep = TransPort.WritePacketResponse.newBuilder();
//        TransPort.WritePacketRequest.Builder rep = TransPort.WritePacketRequest.newBuilder();
//        rep.setSize(0);
//        ctx.channel().writeAndFlush(rep.build()).addListener(new ChannelFutureListener() {
//            @Override
//            public void operationComplete(ChannelFuture channelFuture) throws Exception {
//                if (channelFuture.isSuccess()) {
//                    ChannelUtils.tryToReadIfNeeded(ctx);
//                } else {
//                    ChannelUtils.closeOnFlush(ctx.channel());
//                }
//            }
//        });
//        ReferenceCountUtil.release(msg);
//    }
//}
